var Your_Province_Name    = "Attacker's Information";
var Enemy_Province_Name   = "Defender's Information";

var Your_Race             = 0; var Enemy_Race            = 0;
var Your_Personality      = 0; var Enemy_Personality     = 0;
var Your_Relations        = 0; var Enemy_Relations       = 0;
var Your_Stance           = 0; var Enemy_Stance          = 0;
var Your_Dragon           = 0; var Enemy_Dragon          = 0;
var Your_Soldiers         = 0; var Enemy_Soldiers        = 0;
var Your_Offensive_Units  = 0; var Enemy_Offensive_Units = 0;
var Your_Defensive_Units  = 0; var Enemy_Defensive_Units = 0;
var Your_Elite_Units      = 0; var Enemy_Elite_Units     = 0;
var Your_Land             = 0; var Enemy_Land            = 0;
var Your_NW               = 0; var Enemy_NW              = 0;
var Your_KD_NW            = 0; var Enemy_KD_NW           = 0;
var Your_OME              = 0; var Enemy_OME             = 0;
var Your_DME              = 0; var Enemy_DME             = 0;
var Your_Generals         = 0; var Enemy_Generals        = 0;
var Your_Attack_Time      = 0; var Enemy_Attack_Time     = 0;
var Your_Horses           = 0; var Enemy_Horses          = 0;
var Your_Mercenaries      = 0; var Enemy_Mercenaries     = 0;
var Your_Prisoners        = 0; var Enemy_Prisoners       = 0;
var Your_Military_Sci     = 0; var Enemy_Military_Sci    = 0;
var Your_Recently_Hit     = 0; var Enemy_Recently_Hit    = 0;
var Your_Guard_Station    = 0; var Enemy_Guard_Station   = 0;
var Your_Peasants         = 0; var Enemy_Peasants        = 0;
var Your_Raw_ME           = 0; var Enemy_Raw_ME          = 0;
var Your_BE               = 0; var Enemy_BE              = 0;
var Your_TG               = 0; var Enemy_TG              = 0;
var Your_Forts            = 0; var Enemy_Forts           = 0;
var Your_Rank             = 0; var Enemy_Rank            = 0;

var Your_Monarch_Box      = 0; var Enemy_Monarch_Box     = 0; var Your_Monarch_Bonus    = 0; var Enemy_Monarch_Bonus    = 0;
var Your_Peasants_Box     = 0; var Enemy_Peasants_Box    = 0; var Your_Peasants_Bonus   = 0; var Enemy_Peasants_Bonus   = 0;
var Your_Fanaticism_Box   = 0; var Enemy_Fanaticism_Box  = 0; var Your_Fanaticism_Bonus = 0; var Enemy_Fanaticism_Bonus = 0;
var Your_Aggression_Box   = 0; var Enemy_Aggression_Box  = 0; var Your_Aggression_Bonus = 0; var Enemy_Aggression_Bonus = 0;
var Your_Protection_Box   = 0; var Enemy_Protection_Box  = 0; var Your_Protection_Bonus = 0; var Enemy_Protection_Bonus = 0;
var Your_Plague_Box       = 0; var Enemy_Plague_Box      = 0; var Your_Plague_Bonus     = 0; var Enemy_Plague_Bonus     = 0;

var Your_TG_Bonus         = 0; var Enemy_TG_Bonus        = 0;
var Your_Forts_Bonus      = 0; var Enemy_Forts_Bonus     = 0;
var Your_OME_Bonus        = 0; var Enemy_OME_Bonus       = 0;
var Your_DME_Bonus        = 0; var Enemy_DME_Bonus       = 0;
var Your_Raw_Offense      = 0; var Enemy_Raw_Offense     = 0;
var Your_Mod_Offense      = 0; var Enemy_Mod_Offense     = 0;
var Your_Raw_Defense      = 0; var Enemy_Raw_Defense     = 0;
var Your_Mod_Defense      = 0; var Enemy_Mod_Defense     = 0;
var Your_Ruby_Dragon      = 0; var Enemy_Ruby_Dragon     = 0;

var Your_Optimize1        = 0;
var Your_Optimize2        = 0;
var Your_Rank_Bonus       = 0;

var Your_Optimize_Horses      = 0;
var Your_Optimize_Mercenaries = 0;
var Your_Optimize_Prisoners   = 0;

var Gain_Formula_Cap_Value = 0;
var Gain_Formula_Cap       = 0;
var Gain_Formula_Land      = 0;
var Gain_Formula_PNWF      = 1;
var Gain_Formula_KNWF      = 1;
var Gain_Formula_Race      = 1;
var Gain_Formula_Stance    = 1;
var Gain_Formula_Relations = 1;
var Gain_Formula_Sciences  = 1;
var Gain_Formula_GS        = 1;
var Gain_Formula_Dragon    = 1;
var Gain_Formula_GBP       = 1;
var Gain_Formula_Time      = 1;

var Chance                 = 0;
var Relative_NW            = 1;
var Relative_KD_NW         = 1;
var Main_Gain_Formula      = 1;

function Optimize_Horses() { document.getElementById('YourHorses').value=Your_Optimize_Horses; document.getElementById('YourOptimizeHorses').disabled=true; }
function Max_Merc()  { document.getElementById('YourMerc').value=Your_Optimize_Mercenaries; document.getElementById('YourMaxMerc').disabled=true; }
function Max_Pris()  { document.getElementById('YourPris').value=Your_Optimize_Prisoners; document.getElementById('YourMaxPris').disabled=true; }

function Task_Military() {

Your_Province_Name   = document.getElementById( 'YourProvinceName'  ).innerHTML;
Enemy_Province_Name  = document.getElementById( 'EnemyProvinceName' ).innerHTML;

Your_Race            = Number( document.getElementById('YourRace').value         ); Enemy_Race            = Number( document.getElementById('EnemyRace').value         );
Your_Personality     = Number( document.getElementById('YourPersonality').value  ); Enemy_Personality     = Number( document.getElementById('EnemyPersonality').value  );
Your_Relations       = Number( document.getElementById('YourRelations').value    ); Enemy_Relations       = Number( document.getElementById('EnemyRelations').value    );
Your_Stance          = Number( document.getElementById('YourStance').value       ); Enemy_Stance          = Number( document.getElementById('EnemyStance').value       );
Your_Dragon          = Number( document.getElementById('YourDragon').value       ); Enemy_Dragon          = Number( document.getElementById('EnemyDragon').value       );
Your_Soldiers        = Number( document.getElementById('YourSoldiers').value     ); Enemy_Soldiers        = Number( document.getElementById('EnemySoldiers').value     );
Your_Offensive_Units = Number( document.getElementById('YourOffSpecs').value     ); Enemy_Offensive_Units = Number( document.getElementById('EnemyOffSpecs').value     );
Your_Defensive_Units = Number( document.getElementById('YourDefSpecs').value     ); Enemy_Defensive_Units = Number( document.getElementById('EnemyDefSpecs').value     );
Your_Elite_Units     = Number( document.getElementById('YourElites').value       ); Enemy_Elite_Units     = Number( document.getElementById('EnemyElites').value       );
Your_Land            = Number( document.getElementById('YourLand').value         ); Enemy_Land            = Number( document.getElementById('EnemyLand').value         );
Your_NW              = Number( document.getElementById('YourNW').value           ); Enemy_NW              = Number( document.getElementById('EnemyNW').value           );
Your_KD_NW           = Number( document.getElementById('YourKDNW').value         ); Enemy_KD_NW           = Number( document.getElementById('EnemyKDNW').value         );
Your_OME             = Number( document.getElementById('YourOME').value          ); Enemy_OME             = Number( document.getElementById('EnemyOME').value          );
Your_DME             = Number( document.getElementById('YourDME').value          ); Enemy_DME             = Number( document.getElementById('EnemyDME').value          );
Your_Generals        = Number( document.getElementById('YourGenerals').value     ); Enemy_Generals        = Number( document.getElementById('EnemyGenerals').value     );
Your_Attack_Time     = Number( document.getElementById('YourAttackTime').value   ); Enemy_Attack_Time     = Number( document.getElementById('EnemyAttackTime').value   );
Your_Horses          = Number( document.getElementById('YourHorses').value       ); Enemy_Horses          = Number( document.getElementById('EnemyHorses').value       );
Your_Mercenaries     = Number( document.getElementById('YourMerc').value         ); Enemy_Mercenaries     = Number( document.getElementById('EnemyMerc').value         );
Your_Prisoners       = Number( document.getElementById('YourPris').value         ); Enemy_Prisoners       = Number( document.getElementById('EnemyPris').value         );
Your_Military_Sci    = Number( document.getElementById('YourMilitarySci').value  ); Enemy_Military_Sci    = Number( document.getElementById('EnemyMilitarySci').value  );
Your_Recently_Hit    = Number( document.getElementById('YourRecentlyHit').value  ); Enemy_Recently_Hit    = Number( document.getElementById('EnemyRecentlyHit').value  );
Your_Guard_Station   = Number( document.getElementById('YourGuardStation').value ); Enemy_Guard_Station   = Number( document.getElementById('EnemyGuardStation').value );
Your_Peasants        = Number( document.getElementById('YourPeasants').value     ); Enemy_Peasants        = Number( document.getElementById('EnemyPeasants').value     );
Your_Raw_ME          = Number( document.getElementById('YourRawME').value        ); Enemy_Raw_ME          = Number( document.getElementById('EnemyRawME').value        );
Your_BE              = Number( document.getElementById('YourBE').value           ); Enemy_BE              = Number( document.getElementById('EnemyBE').value           );
Your_TG              = Number( document.getElementById('YourTG').value           ); Enemy_TG              = Number( document.getElementById('EnemyTG').value           );
Your_Forts           = Number( document.getElementById('YourForts').value        ); Enemy_Forts           = Number( document.getElementById('EnemyForts').value        );
Your_Rank            = Number( document.getElementById('YourRank').value         ); Enemy_Rank            = Number( document.getElementById('EnemyRank').value         );

Your_Monarch_Box      = 0; Enemy_Monarch_Box     = 0; Your_Monarch_Bonus    = 0; Enemy_Monarch_Bonus    = 0;
Your_Peasants_Box     = 0; Enemy_Peasants_Box    = 0; Your_Peasants_Bonus   = 0; Enemy_Peasants_Bonus   = 0;
Your_Fanaticism_Box   = 0; Enemy_Fanaticism_Box  = 0; Your_Fanaticism_Bonus = 0; Enemy_Fanaticism_Bonus = 0;
Your_Aggression_Box   = 0; Enemy_Aggression_Box  = 0; Your_Aggression_Bonus = 1; Enemy_Aggression_Bonus = 1;
Your_Protection_Box   = 0; Enemy_Protection_Box  = 0; Your_Protection_Bonus = 0; Enemy_Protection_Bonus = 0;
Your_Plague_Box       = 0; Enemy_Plague_Box      = 0; Your_Plague_Bonus     = 0; Enemy_Plague_Bonus     = 0;

//if ( document.getElementById( 'YourMonarchBox'     ).checked == true ) Your_Monarch_Box     = 1;
if ( document.getElementById( 'YourPeasantsBox'    ).checked == true ) Your_Peasants_Box    = 1;
if ( document.getElementById( 'YourFanaticismBox'  ).checked == true ) Your_Fanaticism_Box  = 1;
if ( document.getElementById( 'YourAggressionBox'  ).checked == true ) Your_Aggression_Box  = 1;
if ( document.getElementById( 'YourProtectionBox'  ).checked == true ) Your_Protection_Box  = 1;
if ( document.getElementById( 'YourPlagueBox'      ).checked == true ) Your_Plague_Box      = 1;

//if ( document.getElementById( 'EnemyMonarchBox'    ).checked == true ) Enemy_Monarch_Box    = 1;
if ( document.getElementById( 'EnemyPeasantsBox'   ).checked == true ) Enemy_Peasants_Box   = 1;
if ( document.getElementById( 'EnemyFanaticismBox' ).checked == true ) Enemy_Fanaticism_Box = 1;
if ( document.getElementById( 'EnemyAggressionBox' ).checked == true ) Enemy_Aggression_Box = 1;
if ( document.getElementById( 'EnemyProtectionBox' ).checked == true ) Enemy_Protection_Box = 1;
if ( document.getElementById( 'EnemyPlagueBox'     ).checked == true ) Enemy_Plague_Box     = 1;

Your_Raw_Offense     = 0; Enemy_Raw_Defense     = 0;
Your_Mod_Offense     = 0; Enemy_Mod_Defense     = 0;
Your_Ruby_Dragon     = 0; Enemy_Ruby_Dragon     = 0;

Your_Optimize1       = 0;
Your_Optimize2       = 0;
Your_Rank_Bonus      = 0;

// **************************
//   Attacker's Information
// **************************

////////////////////////////////////////////
// Aggression :: Faery = 8 , Halfling = 9 //
////////////////////////////////////////////

if (( Your_Race == 8 )||( Your_Race == 9 )) {

document.getElementById( 'YourAggressionBox'  ).disabled = false;
document.getElementById( 'YourAggressionName' ).disabled = false;

} else {

document.getElementById( 'YourAggressionBox'  ).disabled = true;
document.getElementById( 'YourAggressionName' ).disabled = true;

}

document.getElementById('YourOffSpecsName').innerHTML = Offensive_Specialist_Name[Your_Race] ;
document.getElementById('YourElitesName'  ).innerHTML = Elite_Unit_Name[Your_Race] ;

Your_Optimize1 = Your_Soldiers + Your_Offensive_Units + Your_Elite_Units ;

Your_Optimize_Horses = Your_Horses;

if ( Your_Horses > Your_Optimize1 ) { Your_Optimize_Horses = Your_Optimize1; document.getElementById('YourOptimizeHorses').disabled = false; }

if (( document.getElementById('YourAggressionBox').disabled == false )&&( Your_Aggression_Box == 1 )&&( document.getElementById('YourBonusesBox').style.display == "block" )) Your_Aggression_Bonus = 2;

Your_Optimize_Mercenaries = Your_Mercenaries ;
Your_Optimize_Prisoners   = Your_Prisoners   ;

Your_Optimize2 = Math.round( Your_Optimize1 / 5 ) - Your_Prisoners   ; if ( Your_Optimize2 < 0 ) Your_Optimize2 = 0 ;
if ( Your_Mercenaries != Your_Optimize2 ) { Your_Optimize_Mercenaries = Your_Optimize2 ; document.getElementById('YourMaxMerc').disabled = false ; }

Your_Optimize2 = Math.round( Your_Optimize1 / 5 ) - Your_Mercenaries ; if ( Your_Optimize2 < 0 ) Your_Optimize2 = 0 ;
if ( Your_Prisoners != Your_Optimize2   ) { Your_Optimize_Prisoners   = Your_Optimize2 ; document.getElementById('YourMaxPris').disabled = false ; }

if ( Your_Personality == 9 ) {
document.getElementById('YourPersonalityName').innerHTML = '<font color="red">Personality</font>';
} else { document.getElementById('YourPersonalityName').innerHTML = 'Personality'; }

if ( Your_Relations == 5 ) {
document.getElementById('MinimumGain').innerHTML = "Burnt Land"     ;
} else {
document.getElementById('MinimumGain').innerHTML = "Gain With Exploration Pool (War Only)"   ;
}

if ( Your_Relations == 3 ) document.getElementById('EnemyRelations').value = 3; // War

if (( Your_Stance == 2 )&&( Your_Relations != 3 )) Your_Raw_ME = Your_Raw_ME - 15 ; // Fortified

if ( Your_TG > 50 ) { Your_TG = 50; document.getElementById('YourTG').value = 50; }

Your_TG_Bonus = 1.5 * Your_TG * ( 1 - Your_TG / 100 ) * Your_BE / 100;

if ( Your_Rank >  0 ) Your_Rank_Bonus = Your_Rank * 2 -  2 ;
if ( Your_Rank >  4 ) Your_Rank_Bonus = Your_Rank * 4 - 10 ;
if ( Your_Rank >  8 ) Your_Rank_Bonus = 2 ; // King is Unknown so i set it to Lord
if ( Your_Race == 3 ) Your_Rank_Bonus = Math.round( Your_Rank_Bonus / 2 );

if ( Your_Dragon == 1 ) Your_Ruby_Dragon = 8 ;
if ( Your_Dragon != 1 ) Your_Ruby_Dragon = 0 ;

////////////////////////////////////////
// Fanaticism :: Avian = 7, Faery = 8 //
////////////////////////////////////////

if (( Your_Race == 7 )||( Your_Race == 8 )) {

document.getElementById( 'YourFanaticismBox' ).disabled = false ;
document.getElementById( 'YourFanaticism'    ).disabled = false ;

} else {

document.getElementById( 'YourFanaticismBox' ).disabled = true ;
document.getElementById( 'YourFanaticism'    ).disabled = true ;

}

if (( document.getElementById('YourFanaticismBox').disabled == false )&&( Your_Fanaticism_Box == 1 )) Your_Fanaticism_Bonus = 5;

Your_Raw_Offense = Your_Soldiers*Offensive_Soldiers_Strength[Your_Race]*Your_Aggression_Bonus + Your_Offensive_Units*Offensive_Specialist_Strength[Your_Race] + Your_Elite_Units*Offensive_Elite_Unit_Strength[Your_Race] + Your_Optimize_Horses + document.getElementById('YourMerc').value*3 + document.getElementById('YourPris').value*3 ;

if ( document.getElementById('YourBonusesBox').style.display == "block" ) {
Your_OME_Bonus = (Your_Raw_ME)*(1+Your_Generals/100)*(1+Your_TG_Bonus/100)*(1+Your_Rank_Bonus/100)*(1-Your_Ruby_Dragon/100)*(1+Your_Fanaticism_Bonus/100) ;
} else { Your_OME_Bonus = (Your_OME+Your_Generals); }

document.getElementById('YourRawOffense').innerHTML = Your_Raw_Offense;
document.getElementById('YourBonuses').innerHTML = Math.round( ( Your_OME_Bonus/100 - 1 ) * 10000 ) / 100 + "%";
Your_Mod_Offense = Math.round( Your_Raw_Offense * Your_OME_Bonus/100 ) ;
document.getElementById('YourModifiedOffense').innerHTML = Your_Mod_Offense;

if ( Your_Land == 0 ) { document.getElementById('YourModifiedOPA').innerHTML = "?"; } else {
document.getElementById('YourModifiedOPA').innerHTML = Math.round( Your_Mod_Offense / Your_Land * 100 ) / 100 ; }



// **************************
//   Defender's Information
// **************************



document.getElementById('EnemyDefSpecsName').innerHTML = Defensive_Specialist_Name[Enemy_Race];
document.getElementById('EnemyElitesName'  ).innerHTML = Elite_Unit_Name[Enemy_Race];

if ( Enemy_Peasants_Box == 0 ) { document.getElementById('EnemyPeasants').disabled=true;  Enemy_Peasants_Bonus = 0; }
if ( Enemy_Peasants_Box == 1 ) { document.getElementById('EnemyPeasants').disabled=false; Enemy_Peasants_Bonus = Math.round( Enemy_Peasants / 4 ); }

////////////////////////////////////////
// Town Watch :: Undead = 6 Faery = 8 //
////////////////////////////////////////

if (( Enemy_Race == 6 )||( Enemy_Race == 8 )) {

document.getElementById( 'EnemyPeasantsBox'  ).disabled = false ;
document.getElementById( 'EnemyPeasantsName' ).disabled = false ;

} else {

Enemy_Peasants_Bonus = 0;
document.getElementById( 'EnemyPeasantsBox'  ).disabled = true ;
document.getElementById( 'EnemyPeasantsName' ).disabled = true ;

}

////////////////////////
// Freak :: red color //
////////////////////////

if ( Enemy_Personality == 9 ) {

document.getElementById('EnemyPersonalityName').innerHTML = "<font color=red>Personality</font>";

} else {

document.getElementById('EnemyPersonalityName').innerHTML="Personality";

}

/////////////////////////////////////
// Plague :: Undead = 6 Cleric = 7 //
/////////////////////////////////////

if (( Enemy_Race == 6 )||( Enemy_Personality == 7 )) {

document.getElementById( 'EnemyPlagueBox'  ).disabled = true;
document.getElementById( 'EnemyPlagueName' ).disabled = true;

document.getElementById( 'EnemyPlagueBox'  ).checked = false;

} else {

document.getElementById( 'EnemyPlagueBox'  ).disabled = false;
document.getElementById( 'EnemyPlagueName' ).disabled = false;

}

////////////////////////////////////////
// Fanaticism :: Avian = 7, Faery = 8 //
////////////////////////////////////////

if (( Enemy_Race == 7 )||( Enemy_Race == 8 )) {

document.getElementById( 'EnemyFanaticismBox' ).disabled = false;
document.getElementById( 'EnemyFanaticism'    ).disabled = false;

} else {

document.getElementById( 'EnemyFanaticismBox' ).disabled = true;
document.getElementById( 'EnemyFanaticism'    ).disabled = true;

}

if (( document.getElementById('EnemyFanaticismBox').disabled == false )&&( Enemy_Fanaticism_Box == 1 )) Enemy_Fanaticism_Bonus = 3;

if (( Enemy_Stance == 2 )&&( Enemy_Relations != 3 )) Enemy_Raw_ME = Math.round( Enemy_Raw_ME + 10 );

if ( Enemy_Dragon == 1 ) Enemy_Ruby_Dragon=8;
if ( Enemy_Dragon != 1 ) Enemy_Ruby_Dragon=0;

if ( Enemy_Protection_Box == 1 ) Enemy_Protection_Bonus = 5;

if ( Enemy_Plague_Box == 1 ) { document.getElementById('EnemyPlagueImage').style.display = "block"; Enemy_Plague_Bonus = 15; }
if ( Enemy_Plague_Box == 0 ) { document.getElementById('EnemyPlagueImage').style.display = "none";  Enemy_Plague_Bonus = 0;  }

if (( Your_Relations == 3 )||( Your_Relations == 2 )) {

//document.getElementById( 'EnemyMonarchBox'  ).disabled=false;
//document.getElementById( 'EnemyMonarchName' ).disabled=false;

} else {

//document.getElementById( 'EnemyMonarchBox'  ).disabled=true;
//document.getElementById( 'EnemyMonarchName' ).disabled=true;

}

//if (( document.getElementById('EnemyMonarchBox').disabled == false )&&( Enemy_Monarch_Box == 1 )) Enemy_Monarch_Bonus = 10;

if (Enemy_Forts > 50) { Enemy_Forts = 50; document.getElementById('EnemyForts').value = 50; }
Enemy_Forts_Bonus = 1.5 * ( Enemy_Forts - Enemy_Forts * Enemy_Forts / 100 ) * Enemy_BE / 100;

Enemy_Raw_Defense = Enemy_Soldiers*Defensive_Soldiers_Strength[Enemy_Race] + Enemy_Defensive_Units*Defensive_Specialist_Strength[Enemy_Race] + Enemy_Elite_Units*Defensive_Elite_Unit_Strength[Enemy_Race] + Enemy_Peasants_Bonus ;
document.getElementById('EnemyRawDefense').innerHTML=Enemy_Raw_Defense;

if ( document.getElementById('EnemyBonusesBox').style.display == "block" ) {
Enemy_DME_Bonus = (Enemy_Raw_ME)*(1+Enemy_Monarch_Bonus/100)*(1-Enemy_Ruby_Dragon/100)*(1-Enemy_Fanaticism_Bonus/100)*(1+Enemy_Protection_Bonus/100)*(1-Enemy_Plague_Bonus/100)*(1+Enemy_Forts_Bonus/100) ;
} else { Enemy_DME_Bonus = (Enemy_DME)*(1+Enemy_Monarch_Bonus/100); }

document.getElementById('EnemyBonuses').innerHTML = Math.round( ( Enemy_DME_Bonus/100 - 1 ) * 10000 ) / 100 + "%";
Enemy_Mod_Defense = Math.round( Enemy_Raw_Defense * Enemy_DME_Bonus/100 ) ;
document.getElementById('EnemyModifiedDefense').innerHTML = Enemy_Mod_Defense;

if ( Enemy_Land == 0 ) { document.getElementById('EnemyModifiedDPA').innerHTML = "?"; } else {
document.getElementById('EnemyModifiedDPA').innerHTML = Math.round( Enemy_Mod_Defense / Enemy_Land * 100 ) / 100 ; }



// **************************
//   Gain Formula Modifiers
// **************************



if ( Your_NW > 0 ) { Relative_NW = Enemy_NW / Your_NW ;
if ( Relative_NW < 0.9 ) Gain_Formula_PNWF = 3 * Relative_NW - 1.7 ;
if (( 0.9 <= Relative_NW )&&( Relative_NW <= 1.1 )) Gain_Formula_PNWF = 1 ;
if ( Relative_NW > 1.1 ) Gain_Formula_PNWF = -2 * Relative_NW + 3.2 ;
} else { Gain_Formula_PNWF = 1 ; }

if ( Your_KD_NW > 0 ) { Relative_KD_NW = Enemy_KD_NW / Your_KD_NW ;
if ( Relative_KD_NW < 0.4 ) Gain_Formula_KNWF = 2/3;
if (( 0.4 <= Relative_KD_NW )&&( Relative_KD_NW <= 0.9 )) Gain_Formula_KNWF = Relative_KD_NW * 2/3 + 0.4 ;
if ( Relative_KD_NW > 0.9 ) Gain_Formula_KNWF = 1 ;
} else { Gain_Formula_KNWF = 1 ; }

if ( Gain_Formula_PNWF < 0 ) Gain_Formula_PNWF = 0 ;

Gain_Formula_Land = Enemy_Land * 0.12 ;

Gain_Formula_Race = 1;

if ( Your_Race == 0 ) Gain_Formula_Race = 0.8; // Human
if ( Your_Race == 3 ) Gain_Formula_Race = 1.3; // Orc



if ( Your_Stance == 3 ) Gain_Formula_Stance = 1.1;
if ( Your_Stance != 3 ) Gain_Formula_Stance = 1;

if ( Enemy_Relations == 2 ) Gain_Formula_Relations = 1.1;
if ( Enemy_Relations != 2 ) Gain_Formula_Relations = 1;

Gain_Formula_Time     = 1 + Your_Attack_Time  / 100 ;
Gain_Formula_Sciences = 1 + Your_Military_Sci / 100 ;

if ( Enemy_Guard_Station > 50 ) { Enemy_Guard_Station = 50; document.getElementById('EnemyGuardStation').value = 50; }
Gain_Formula_GS = Building_Modifier_Attacked_Losses * ( Enemy_Guard_Station / 100 ) * Enemy_BE * ( 1 - ( Enemy_Guard_Station / 100 ) ) ;
Gain_Formula_GS = 1 - Gain_Formula_GS / 100 ;

// Emerald Dragon Check

if ( Your_Dragon == 2 ) Gain_Formula_Dragon = 0.85;
if ( Your_Dragon != 2 ) Gain_Formula_Dragon = 1;

///////////////////////////////////////////
// The War Hero Immune to dragon effects //
///////////////////////////////////////////

if ( Your_Personality == 2 ) Gain_Formula_Dragon = 1;

if ( Enemy_Relations != 3 ) Gain_Formula_GBP = 100 - 20 * Enemy_Recently_Hit ;
if ( Enemy_Relations == 3 ) Gain_Formula_GBP = 100 -  5 * Enemy_Recently_Hit ;

Gain_Formula_GBP = Gain_Formula_GBP / 100 ;

document.getElementById( 'GainFormulaLand'      ).innerHTML = Math.round( Gain_Formula_Land      * 100 ) / 100 ;
document.getElementById( 'GainFormulaPNWF'      ).innerHTML = Math.round( Gain_Formula_PNWF      * 100 ) / 100 ;
document.getElementById( 'GainFormulaKNWF'      ).innerHTML = Math.round( Gain_Formula_KNWF      * 100 ) / 100 ;
document.getElementById( 'GainFormulaRace'      ).innerHTML = Math.round( Gain_Formula_Race      * 100 ) / 100 ;
document.getElementById( 'GainFormulaStance'    ).innerHTML = Math.round( Gain_Formula_Stance    * 100 ) / 100 ;
document.getElementById( 'GainFormulaRelations' ).innerHTML = Math.round( Gain_Formula_Relations * 100 ) / 100 ;
document.getElementById( 'GainFormulaSciences'  ).innerHTML = Math.round( Gain_Formula_Sciences  * 100 ) / 100 ;
document.getElementById( 'GainFormulaGS'        ).innerHTML = Math.round( Gain_Formula_GS        * 100 ) / 100 ;
document.getElementById( 'GainFormulaDragon'    ).innerHTML = Math.round( Gain_Formula_Dragon    * 100 ) / 100 ;
document.getElementById( 'GainFormulaGBP'       ).innerHTML = Math.round( Gain_Formula_GBP       * 100 ) / 100 ;
document.getElementById( 'GainFormulaTime'      ).innerHTML = Math.round( Gain_Formula_Time      * 100 ) / 100 ;

Main_Gain_Formula = Gain_Formula_Land * Gain_Formula_PNWF * Gain_Formula_KNWF * Gain_Formula_Race * Gain_Formula_Stance * Gain_Formula_Relations * Gain_Formula_Sciences * Gain_Formula_GS * Gain_Formula_Dragon * Gain_Formula_GBP * Gain_Formula_Time ;

if ( Your_Relations == 3 ) { Gain_Formula_Cap_Value = 0.2; } else { Gain_Formula_Cap_Value = 0.162; }

if ( Your_Land < Enemy_Land ) { Gain_Formula_Cap = Your_Land * Gain_Formula_Cap_Value ; } else { Gain_Formula_Cap = Enemy_Land * Gain_Formula_Cap_Value ; }


if ( Main_Gain_Formula > Gain_Formula_Cap ) Main_Gain_Formula = Gain_Formula_Cap ;


if ( Your_Relations == 5 ) {

document.getElementById( 'MainGainFormula'      ).innerHTML = Math.round( Main_Gain_Formula*0.2 ) ;
document.getElementById( 'MainGainFormula2'     ).innerHTML = Math.round( Main_Gain_Formula*0.8 ) ;

} else {

document.getElementById( 'MainGainFormula'      ).innerHTML = Math.round( Main_Gain_Formula ) ;
document.getElementById( 'MainGainFormula2'     ).innerHTML = Math.round( Main_Gain_Formula/Gain_Formula_Cap_Value*(Gain_Formula_Cap_Value +0.02) ) ;

}


// ****************************
//   Attack Result Estimation
// ****************************



if (( Your_Mod_Offense == 0 )&&( Enemy_Mod_Defense == 0 )) { Chance=0; } else { Chance = Your_Mod_Offense/Enemy_Mod_Defense-1 ; }

if (( Chance >  0 )&&( Enemy_Mod_Defense >  0 )) document.getElementById( 'ChanceInfo' ).innerHTML = "You have "+Math.round( Chance * 10000 ) / 100+"% more than enemy's Defensive strength" ;
if (( Chance >  0 )&&( Enemy_Mod_Defense == 0 )) document.getElementById( 'ChanceInfo' ).innerHTML = "Enemy has no Defense" ;

if (( Chance <  0 )&&( Your_Mod_Offense  >  0 )) document.getElementById( 'ChanceInfo' ).innerHTML = "You have "+Math.round( Chance * -10000 ) / 100+"% less than enemy's Defensive strength" ;
if (( Chance <  0 )&&( Your_Mod_Offense  == 0 )) document.getElementById( 'ChanceInfo' ).innerHTML = "You dont have any Offense" ;

if ( Chance == 0 ) document.getElementById( 'ChanceInfo' ).innerHTML = "You have the same strength as your enemy" ;

var RP = 1; // Intel Range %
var RF = 3.5; // Random Factor %

if ( document.getElementById('EspionageR0').disabled  == true ) RP = 1.00; // 0% Range
//if ( document.getElementById('EspionageR3').disabled  == true ) RP = 0.97; // 3% Range
if ( document.getElementById('EspionageR25').disabled == true ) RP = 0.75; // 25% Range

Chance = (100/RF)*(1-2/(1+(Your_Mod_Offense/Enemy_Mod_Defense)*(RP/0.97)))

if ( Chance >  1 ) Chance =  1
if ( Chance < -1 ) Chance = -1

Chance = -25*(Chance)*(Chance)*(Chance)+75*(Chance)+50 ;

Chance = Math.floor( Chance*10 )/10 ;

if (( 0  < Chance )&&( Chance <= 25 )) document.getElementById('ChanceBar').style.background="#AF0000";
if (( 25 < Chance )&&( Chance <= 50 )) document.getElementById('ChanceBar').style.background="#C8009B";
if (( 50 < Chance )&&( Chance <= 75 )) document.getElementById('ChanceBar').style.background="#9A00DA";
if (( 75 < Chance )&&( Chance < 100 )) document.getElementById('ChanceBar').style.background="#0000AF";

if (( Your_Mod_Offense == 0 )&&( Enemy_Mod_Defense == 0 )) {
document.getElementById('ChanceBar').style.width="0px";
document.getElementById('Chance').innerHTML="<font color='#000000'>?</font>";
} else {

if ( (0  < Chance)&&(Chance <= 25) ) document.getElementById('Chance').innerHTML="<font color='#AF0000'>"+Chance+"%</font>";
if ( (25 < Chance)&&(Chance <= 50) ) document.getElementById('Chance').innerHTML="<font color='#C8009B'>"+Chance+"%</font>";
if ( (50 < Chance)&&(Chance <= 75) ) document.getElementById('Chance').innerHTML="<font color='#9A00DA'>"+Chance+"%</font>";
if ( (75 < Chance)&&(Chance < 100) ) document.getElementById('Chance').innerHTML="<font color='#0000AF'>"+Chance+"%</font>";

document.getElementById('ChanceBar').style.width=Chance+"%";

if (Chance==0) {
document.getElementById('Chance').innerHTML="<font color='#000000'>"+Chance+"%</font>";
document.getElementById('ChanceBar').style.width="100%";
document.getElementById('ChanceBar').style.background="#000000";
}

if (Chance==100) {
document.getElementById('Chance').innerHTML="<font color='#006400'>"+Chance+"%</font>";
document.getElementById('ChanceBar').style.width="100%";
document.getElementById('ChanceBar').style.background="#006400";
}

}





}


function YourBonuses() {

if ( document.getElementById('YourBonusesBox').style.display == "block" ) {
document.getElementById('YourBonusesBox').style.display = "none"; } else {
document.getElementById('SpecialBox').style.display = "none";
document.getElementById('GainFormulaBox').style.display = "none";
document.getElementById('YourBonusesBox').style.display = "block"; }

if (( document.getElementById('YourBonusesBox').style.display == "none" )&&( document.getElementById('EnemyBonusesBox').style.display == "none" )) {
if ( document.getElementById('Special').value == "Special" ) {
document.getElementById('SpecialBox').style.display = "none";
document.getElementById('GainFormulaBox').style.display = "block";
} else {
document.getElementById('GainFormulaBox').style.display = "none";
document.getElementById('SpecialBox').style.display = "block";
}
}


}

function EnemyBonuses() {

if ( document.getElementById('EnemyBonusesBox').style.display == "block" ) {
document.getElementById('EnemyBonusesBox').style.display = "none"; } else {
document.getElementById('SpecialBox').style.display = "none";
document.getElementById('GainFormulaBox' ).style.display = "none"; 
document.getElementById('EnemyBonusesBox').style.display = "block"; }

if (( document.getElementById('YourBonusesBox').style.display == "none" )&&( document.getElementById('EnemyBonusesBox').style.display == "none" )) {
if ( document.getElementById('Special').value == "Special" ) {
document.getElementById('SpecialBox').style.display = "none";
document.getElementById('GainFormulaBox').style.display = "block";
} else {
document.getElementById('GainFormulaBox').style.display = "none";
document.getElementById('SpecialBox').style.display = "block";
}
}


}



function SpecialBox() {

if ( document.getElementById('Special').value == "Special" ) {
if (( document.getElementById('YourBonusesBox').style.display == "none" )&&( document.getElementById('EnemyBonusesBox').style.display == "none" )) {
document.getElementById('GainFormulaBox').style.display = "none";
document.getElementById('SpecialBox').style.display = "block";
}
document.getElementById('Special').value = "Modifiers";
} else {
if (( document.getElementById('YourBonusesBox').style.display == "none" )&&( document.getElementById('EnemyBonusesBox').style.display == "none" )) {
document.getElementById('SpecialBox').style.display = "none";
document.getElementById('GainFormulaBox').style.display = "block";
}
document.getElementById('Special').value = "Special";
}

}


function EspionageRange0() {

document.getElementById('EspionageR0').disabled  = true  ;
//document.getElementById('EspionageR3').disabled  = false ;
document.getElementById('EspionageR25').disabled = false ;

document.getElementById( 'EspionageInfo' ).innerHTML = "Espionage Is 100% Accurate" ;

}

// 
// Removed!!!!
// 
// function EspionageRange3() {
// 
// document.getElementById('EspionageR0').disabled  = false ;
// document.getElementById('EspionageR3').disabled  = true  ;
// document.getElementById('EspionageR25').disabled = false ;
// 
// document.getElementById( 'EspionageInfo' ).innerHTML = "Randomization Factor Is 3%" ;
// 
// }
// 

function EspionageRange25() {

document.getElementById('EspionageR0').disabled  = false ;
//document.getElementById('EspionageR3').disabled  = false ;
document.getElementById('EspionageR25').disabled = true  ;

document.getElementById( 'EspionageInfo' ).innerHTML = "Randomization Factor Is 25%" ;

}



function YourReset() {

document.getElementById( 'YourProvinceName' ).innerHTML = "Attacker's Information";

document.getElementById('YourRace').value            = 0;
document.getElementById('YourPersonality').value     = 0;
document.getElementById('YourRelations').value       = 0;
document.getElementById('YourStance').value          = 0;
document.getElementById('YourDragon').value          = 0;
document.getElementById('YourSoldiers').value        = 0;
document.getElementById('YourOffSpecs').value        = 0;
document.getElementById('YourDefSpecs').value        = 0;
document.getElementById('YourElites').value          = 0;
document.getElementById('YourLand').value            = 0;
document.getElementById('YourNW').value              = 0;
document.getElementById('YourKDNW').value            = 0;
document.getElementById('YourOME').value             = 100;
document.getElementById('YourDME').value             = 100;
document.getElementById('YourGenerals').value        = 0;
document.getElementById('YourAttackTime').value      = 0;
document.getElementById('YourHorses').value          = 0; document.getElementById('YourOptimizeHorses').disabled = true;
document.getElementById('YourMerc').value            = 0; document.getElementById('YourMaxMerc').disabled        = true;
document.getElementById('YourPris').value            = 0; document.getElementById('YourMaxPris').disabled        = true;
document.getElementById('YourMilitarySci').value     = 0;
document.getElementById('YourRecentlyHit').value     = 0;
document.getElementById('YourGuardStation').value    = 0;
document.getElementById('YourPeasants').value        = 0;
document.getElementById('YourRawME').value           = 100;
document.getElementById('YourBE').value              = 100;
document.getElementById('YourTG').value              = 0;
document.getElementById('YourForts').value           = 0;
document.getElementById('YourRank').value            = 0;
document.getElementById('YourFanaticismBox').checked = false;
document.getElementById('YourAggressionBox').checked = false;
document.getElementById('YourProtectionBox').checked = true;
document.getElementById('YourPlagueBox').checked     = false;

}

function EnemyReset() {

document.getElementById( 'EnemyProvinceName' ).innerHTML = "Defender's Information";
document.getElementById( 'EnemyPlagueImage'  ).style.display = "none";

document.getElementById('EnemyRace').value            = 0;
document.getElementById('EnemyPersonality').value     = 0;
document.getElementById('EnemyRelations').value       = 0;
document.getElementById('EnemyStance').value          = 0;
document.getElementById('EnemyDragon').value          = 0;
document.getElementById('EnemySoldiers').value        = 0;
document.getElementById('EnemyOffSpecs').value        = 0;
document.getElementById('EnemyDefSpecs').value        = 0;
document.getElementById('EnemyElites').value          = 0;
document.getElementById('EnemyLand').value            = 0;
document.getElementById('EnemyNW').value              = 0;
document.getElementById('EnemyKDNW').value            = 0;
document.getElementById('EnemyOME').value             = 100;
document.getElementById('EnemyDME').value             = 100;
document.getElementById('EnemyGenerals').value        = 0;
document.getElementById('EnemyAttackTime').value      = 0;
document.getElementById('EnemyHorses').value          = 0;
document.getElementById('EnemyMerc').value            = 0;
document.getElementById('EnemyPris').value            = 0;
document.getElementById('EnemyMilitarySci').value     = 0;
document.getElementById('EnemyRecentlyHit').value     = 0;
document.getElementById('EnemyGuardStation').value    = 0;
document.getElementById('EnemyPeasants').value        = 0;
document.getElementById('EnemyRawME').value           = 100;
document.getElementById('EnemyBE').value              = 100;
document.getElementById('EnemyTG').value              = 0;
document.getElementById('EnemyForts').value           = 0;
document.getElementById('EnemyRank').value            = 0;
document.getElementById('EnemyFanaticismBox').checked = false;
document.getElementById('EnemyAggressionBox').checked = false;
document.getElementById('EnemyProtectionBox').checked = true;
document.getElementById('EnemyPlagueBox').checked     = false;

}

function YourMove() {

if ( Enemy_Province_Name != "Defender's Information" ) document.getElementById( 'YourProvinceName'  ).innerHTML = Enemy_Province_Name ;

document.getElementById('YourRace').value         = Enemy_Race            ;
document.getElementById('YourPersonality').value  = Enemy_Personality     ;
document.getElementById('YourRelations').value    = Enemy_Relations       ;
document.getElementById('YourStance').value       = Enemy_Stance          ;
document.getElementById('YourDragon').value       = Enemy_Dragon          ;
document.getElementById('YourSoldiers').value     = Enemy_Soldiers        ;
document.getElementById('YourOffSpecs').value     = Enemy_Offensive_Units ;
document.getElementById('YourDefSpecs').value     = Enemy_Defensive_Units ;
document.getElementById('YourElites').value       = Enemy_Elite_Units     ;
document.getElementById('YourLand').value         = Enemy_Land            ;
document.getElementById('YourNW').value           = Enemy_NW              ;
document.getElementById('YourKDNW').value         = Enemy_KD_NW           ;
document.getElementById('YourOME').value          = Enemy_OME             ;
document.getElementById('YourDME').value          = Enemy_DME             ;
document.getElementById('YourGenerals').value     = Enemy_Generals        ;
document.getElementById('YourAttackTime').value   = Enemy_Attack_Time     ;
document.getElementById('YourHorses').value       = Enemy_Horses          ;
document.getElementById('YourMerc').value         = Enemy_Mercenaries     ;
document.getElementById('YourPris').value         = Enemy_Prisoners       ;
document.getElementById('YourMilitarySci').value  = Enemy_Military_Sci    ;
document.getElementById('YourRecentlyHit').value  = Enemy_Recently_Hit    ;
document.getElementById('YourGuardStation').value = Enemy_Guard_Station   ;
document.getElementById('YourPeasants').value     = Enemy_Peasants        ;
document.getElementById('YourRawME').value        = Enemy_Raw_ME          ;
document.getElementById('YourBE').value           = Enemy_BE              ;
document.getElementById('YourTG').value           = Enemy_TG              ;
document.getElementById('YourForts').value        = Enemy_Forts           ;
document.getElementById('YourRank').value         = Enemy_Rank            ;

if ( Enemy_Monarch_Box    == 0 ) document.getElementById('YourMonarchBox').checked    = false ;
if ( Enemy_Peasants_Box   == 0 ) document.getElementById('YourPeasantsBox').checked   = false ;
if ( Enemy_Fanaticism_Box == 0 ) document.getElementById('YourFanaticismBox').checked = false ;
if ( Enemy_Aggression_Box == 0 ) document.getElementById('YourAggressionBox').checked = false ;
if ( Enemy_Protection_Box == 0 ) document.getElementById('YourProtectionBox').checked = false ;
if ( Enemy_Plague_Box     == 0 ) document.getElementById('YourPlagueBox').checked     = false ;

if ( Enemy_Monarch_Box    == 1 ) document.getElementById('YourMonarchBox').checked    = true ;
if ( Enemy_Peasants_Box   == 1 ) document.getElementById('YourPeasantsBox').checked   = true ;
if ( Enemy_Fanaticism_Box == 1 ) document.getElementById('YourFanaticismBox').checked = true ;
if ( Enemy_Aggression_Box == 1 ) document.getElementById('YourAggressionBox').checked = true ;
if ( Enemy_Protection_Box == 1 ) document.getElementById('YourProtectionBox').checked = true ;
if ( Enemy_Plague_Box     == 1 ) document.getElementById('YourPlagueBox').checked     = true ;

}

function EnemyMove() {

if ( Your_Province_Name  != "Attacker's Information" ) document.getElementById( 'EnemyProvinceName' ).innerHTML = Your_Province_Name  ;

document.getElementById('EnemyRace').value         = Your_Race            ;
document.getElementById('EnemyPersonality').value  = Your_Personality     ;
document.getElementById('EnemyRelations').value    = Your_Relations       ;
document.getElementById('EnemyStance').value       = Your_Stance          ;
document.getElementById('EnemyDragon').value       = Your_Dragon          ;
document.getElementById('EnemySoldiers').value     = Your_Soldiers        ;
document.getElementById('EnemyOffSpecs').value     = Your_Offensive_Units ;
document.getElementById('EnemyDefSpecs').value     = Your_Defensive_Units ;
document.getElementById('EnemyElites').value       = Your_Elite_Units     ;
document.getElementById('EnemyLand').value         = Your_Land            ;
document.getElementById('EnemyNW').value           = Your_NW              ;
document.getElementById('EnemyKDNW').value         = Your_KD_NW           ;
document.getElementById('EnemyOME').value          = Your_OME             ;
document.getElementById('EnemyDME').value          = Your_DME             ;
document.getElementById('EnemyGenerals').value     = Your_Generals        ;
document.getElementById('EnemyAttackTime').value   = Your_Attack_Time     ;
document.getElementById('EnemyHorses').value       = Your_Horses          ;
document.getElementById('EnemyMerc').value         = Your_Mercenaries     ;
document.getElementById('EnemyPris').value         = Your_Prisoners       ;
document.getElementById('EnemyMilitarySci').value  = Your_Military_Sci    ;
document.getElementById('EnemyRecentlyHit').value  = Your_Recently_Hit    ;
document.getElementById('EnemyGuardStation').value = Your_Guard_Station   ;
document.getElementById('EnemyPeasants').value     = Your_Peasants        ;
document.getElementById('EnemyRawME').value        = Your_Raw_ME          ;
document.getElementById('EnemyBE').value           = Your_BE              ;
document.getElementById('EnemyTG').value           = Your_TG              ;
document.getElementById('EnemyForts').value        = Your_Forts           ;
document.getElementById('EnemyRank').value         = Your_Rank            ;

if ( Your_Monarch_Box    == 0 ) document.getElementById('EnemyMonarchBox').checked    = false ;
if ( Your_Peasants_Box   == 0 ) document.getElementById('EnemyPeasantsBox').checked   = false ;
if ( Your_Fanaticism_Box == 0 ) document.getElementById('EnemyFanaticismBox').checked = false ;
if ( Your_Aggression_Box == 0 ) document.getElementById('EnemyAggressionBox').checked = false ;
if ( Your_Protection_Box == 0 ) document.getElementById('EnemyProtectionBox').checked = false ;
if ( Your_Plague_Box     == 0 ) document.getElementById('EnemyPlagueBox').checked     = false ;

if ( Your_Monarch_Box    == 1 ) document.getElementById('EnemyMonarchBox').checked    = true ;
if ( Your_Peasants_Box   == 1 ) document.getElementById('EnemyPeasantsBox').checked   = true ;
if ( Your_Fanaticism_Box == 1 ) document.getElementById('EnemyFanaticismBox').checked = true ;
if ( Your_Aggression_Box == 1 ) document.getElementById('EnemyAggressionBox').checked = true ;
if ( Your_Protection_Box == 1 ) document.getElementById('EnemyProtectionBox').checked = true ;
if ( Your_Plague_Box     == 1 ) document.getElementById('EnemyPlagueBox').checked     = true ;

}

function Swap() {

if ( Enemy_Province_Name != "Defender's Information" ) document.getElementById( 'YourProvinceName'  ).innerHTML = Enemy_Province_Name ;
if ( Your_Province_Name  != "Attacker's Information" ) document.getElementById( 'EnemyProvinceName' ).innerHTML = Your_Province_Name  ;

if ( Enemy_Province_Name == "Defender's Information" ) document.getElementById( 'YourProvinceName'  ).innerHTML = "Attacker's Information" ;
if ( Your_Province_Name  == "Attacker's Information" ) document.getElementById( 'EnemyProvinceName' ).innerHTML = "Defender's Information" ;

document.getElementById('YourRace').value         = Enemy_Race            ; document.getElementById('EnemyRace').value         = Your_Race            ;
document.getElementById('YourPersonality').value  = Enemy_Personality     ; document.getElementById('EnemyPersonality').value  = Your_Personality     ;
document.getElementById('YourRelations').value    = Enemy_Relations       ; document.getElementById('EnemyRelations').value    = Your_Relations       ;
document.getElementById('YourStance').value       = Enemy_Stance          ; document.getElementById('EnemyStance').value       = Your_Stance          ;
document.getElementById('YourDragon').value       = Enemy_Dragon          ; document.getElementById('EnemyDragon').value       = Your_Dragon          ;
document.getElementById('YourSoldiers').value     = Enemy_Soldiers        ; document.getElementById('EnemySoldiers').value     = Your_Soldiers        ;
document.getElementById('YourOffSpecs').value     = Enemy_Offensive_Units ; document.getElementById('EnemyOffSpecs').value     = Your_Offensive_Units ;
document.getElementById('YourDefSpecs').value     = Enemy_Defensive_Units ; document.getElementById('EnemyDefSpecs').value     = Your_Defensive_Units ;
document.getElementById('YourElites').value       = Enemy_Elite_Units     ; document.getElementById('EnemyElites').value       = Your_Elite_Units     ;
document.getElementById('YourLand').value         = Enemy_Land            ; document.getElementById('EnemyLand').value         = Your_Land            ;
document.getElementById('YourNW').value           = Enemy_NW              ; document.getElementById('EnemyNW').value           = Your_NW              ;
document.getElementById('YourKDNW').value         = Enemy_KD_NW           ; document.getElementById('EnemyKDNW').value         = Your_KD_NW           ;
document.getElementById('YourOME').value          = Enemy_OME             ; document.getElementById('EnemyOME').value          = Your_OME             ;
document.getElementById('YourDME').value          = Enemy_DME             ; document.getElementById('EnemyDME').value          = Your_DME             ;
document.getElementById('YourGenerals').value     = Enemy_Generals        ; document.getElementById('EnemyGenerals').value     = Your_Generals        ;
document.getElementById('YourAttackTime').value   = Enemy_Attack_Time     ; document.getElementById('EnemyAttackTime').value   = Your_Attack_Time     ;
document.getElementById('YourHorses').value       = Enemy_Horses          ; document.getElementById('EnemyHorses').value       = Your_Horses          ;
document.getElementById('YourMerc').value         = Enemy_Mercenaries     ; document.getElementById('EnemyMerc').value         = Your_Mercenaries     ;
document.getElementById('YourPris').value         = Enemy_Prisoners       ; document.getElementById('EnemyPris').value         = Your_Prisoners       ;
document.getElementById('YourMilitarySci').value  = Enemy_Military_Sci    ; document.getElementById('EnemyMilitarySci').value  = Your_Military_Sci    ;
document.getElementById('YourRecentlyHit').value  = Enemy_Recently_Hit    ; document.getElementById('EnemyRecentlyHit').value  = Your_Recently_Hit    ;
document.getElementById('YourGuardStation').value = Enemy_Guard_Station   ; document.getElementById('EnemyGuardStation').value = Your_Guard_Station   ;
document.getElementById('YourPeasants').value     = Enemy_Peasants        ; document.getElementById('EnemyPeasants').value     = Your_Peasants        ;
document.getElementById('YourRawME').value        = Enemy_Raw_ME          ; document.getElementById('EnemyRawME').value        = Your_Raw_ME          ;
document.getElementById('YourBE').value           = Enemy_BE              ; document.getElementById('EnemyBE').value           = Your_BE              ;
document.getElementById('YourTG').value           = Enemy_TG              ; document.getElementById('EnemyTG').value           = Your_TG              ;
document.getElementById('YourForts').value        = Enemy_Forts           ; document.getElementById('EnemyForts').value        = Your_Forts           ;
document.getElementById('YourRank').value         = Enemy_Rank            ; document.getElementById('EnemyRank').value         = Your_Rank            ;

if ( Enemy_Monarch_Box    == 0 ) document.getElementById('YourMonarchBox').checked    = false ;
if ( Enemy_Peasants_Box   == 0 ) document.getElementById('YourPeasantsBox').checked   = false ;
if ( Enemy_Fanaticism_Box == 0 ) document.getElementById('YourFanaticismBox').checked = false ;
if ( Enemy_Aggression_Box == 0 ) document.getElementById('YourAggressionBox').checked = false ;
if ( Enemy_Protection_Box == 0 ) document.getElementById('YourProtectionBox').checked = false ;
if ( Enemy_Plague_Box     == 0 ) document.getElementById('YourPlagueBox').checked     = false ;

if ( Enemy_Monarch_Box    == 1 ) document.getElementById('YourMonarchBox').checked    = true ;
if ( Enemy_Peasants_Box   == 1 ) document.getElementById('YourPeasantsBox').checked   = true ;
if ( Enemy_Fanaticism_Box == 1 ) document.getElementById('YourFanaticismBox').checked = true ;
if ( Enemy_Aggression_Box == 1 ) document.getElementById('YourAggressionBox').checked = true ;
if ( Enemy_Protection_Box == 1 ) document.getElementById('YourProtectionBox').checked = true ;
if ( Enemy_Plague_Box     == 1 ) document.getElementById('YourPlagueBox').checked     = true ;

if ( Your_Monarch_Box    == 0 ) document.getElementById('EnemyMonarchBox').checked    = false ;
if ( Your_Peasants_Box   == 0 ) document.getElementById('EnemyPeasantsBox').checked   = false ;
if ( Your_Fanaticism_Box == 0 ) document.getElementById('EnemyFanaticismBox').checked = false ;
if ( Your_Aggression_Box == 0 ) document.getElementById('EnemyAggressionBox').checked = false ;
if ( Your_Protection_Box == 0 ) document.getElementById('EnemyProtectionBox').checked = false ;
if ( Your_Plague_Box     == 0 ) document.getElementById('EnemyPlagueBox').checked     = false ;

if ( Your_Monarch_Box    == 1 ) document.getElementById('EnemyMonarchBox').checked    = true ;
if ( Your_Peasants_Box   == 1 ) document.getElementById('EnemyPeasantsBox').checked   = true ;
if ( Your_Fanaticism_Box == 1 ) document.getElementById('EnemyFanaticismBox').checked = true ;
if ( Your_Aggression_Box == 1 ) document.getElementById('EnemyAggressionBox').checked = true ;
if ( Your_Protection_Box == 1 ) document.getElementById('EnemyProtectionBox').checked = true ;
if ( Your_Plague_Box     == 1 ) document.getElementById('EnemyPlagueBox').checked     = true ;

}





var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); 

document.getElementById('YourProvinceName').innerHTML = prefService.getCharPref('extensions.Ultima.MilitaryCalculatorYourProvinceName' );

document.getElementById('YourRace').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourRace'          );
document.getElementById('YourPersonality').value  = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourPersonality'   );
document.getElementById('YourRelations').value    = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourRelations'     );
document.getElementById('YourStance').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourStance'        );
document.getElementById('YourDragon').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourDragon'        );
document.getElementById('YourSoldiers').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourSoldiers'      );
document.getElementById('YourOffSpecs').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourOffSpecs'      );
document.getElementById('YourDefSpecs').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourDefSpecs'      );
document.getElementById('YourElites').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourElites'        );
document.getElementById('YourLand').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourLand'          );
document.getElementById('YourNW').value           = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourNW'            );
document.getElementById('YourKDNW').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourKDNW'          );
document.getElementById('YourOME').value          = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourOME'           ) / 1000000;
document.getElementById('YourDME').value          = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourDME'           ) / 1000000;
document.getElementById('YourGenerals').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourGenerals'      );
document.getElementById('YourAttackTime').value   = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourAttackTime'    );
document.getElementById('YourHorses').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourHorses'        );
document.getElementById('YourMerc').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourMerc'          );
document.getElementById('YourPris').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourPris'          );
document.getElementById('YourMilitarySci').value  = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourMilitarySci'   );
document.getElementById('YourRecentlyHit').value  = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourRecentlyHit'   );
document.getElementById('YourGuardStation').value = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourGuardStation'  );
document.getElementById('YourPeasants').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourPeasants'      );
document.getElementById('YourRawME').value        = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourRawME'         );
document.getElementById('YourBE').value           = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourBE'            );
document.getElementById('YourTG').value           = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourTG'            );
document.getElementById('YourForts').value        = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourForts'         );
document.getElementById('YourRank').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorYourRank'          );

document.getElementById('YourMonarchBox').checked    = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorYourMonarchBox'    );
document.getElementById('YourPeasantsBox').checked   = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorYourPeasantsBox'   );
document.getElementById('YourFanaticismBox').checked = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorYourFanaticismBox' );
document.getElementById('YourAggressionBox').checked = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorYourAggressionBox' );
document.getElementById('YourProtectionBox').checked = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorYourProtectionBox' );
document.getElementById('YourPlagueBox').checked     = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorYourPlagueBox'     );

document.getElementById('EnemyProvinceName').innerHTML = prefService.getCharPref('extensions.Ultima.MilitaryCalculatorEnemyProvinceName' );

document.getElementById('EnemyRace').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyRace'          );
document.getElementById('EnemyPersonality').value  = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyPersonality'   );
document.getElementById('EnemyRelations').value    = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyRelations'     );
document.getElementById('EnemyStance').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyStance'        );
document.getElementById('EnemyDragon').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyDragon'        );
document.getElementById('EnemySoldiers').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemySoldiers'      );
document.getElementById('EnemyOffSpecs').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyOffSpecs'      );
document.getElementById('EnemyDefSpecs').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyDefSpecs'      );
document.getElementById('EnemyElites').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyElites'        );
document.getElementById('EnemyLand').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyLand'          );
document.getElementById('EnemyNW').value           = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyNW'            );
document.getElementById('EnemyKDNW').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyKDNW'          );
document.getElementById('EnemyOME').value          = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyOME'           ) / 1000000;
document.getElementById('EnemyDME').value          = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyDME'           ) / 1000000;
document.getElementById('EnemyGenerals').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyGenerals'      );
document.getElementById('EnemyAttackTime').value   = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyAttackTime'    );
document.getElementById('EnemyHorses').value       = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyHorses'        );
document.getElementById('EnemyMerc').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyMerc'          );
document.getElementById('EnemyPris').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyPris'          );
document.getElementById('EnemyMilitarySci').value  = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyMilitarySci'   );
document.getElementById('EnemyRecentlyHit').value  = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyRecentlyHit'   );
document.getElementById('EnemyGuardStation').value = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyGuardStation'  );
document.getElementById('EnemyPeasants').value     = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyPeasants'      );
document.getElementById('EnemyRawME').value        = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyRawME'         );
document.getElementById('EnemyBE').value           = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyBE'            );
document.getElementById('EnemyTG').value           = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyTG'            );
document.getElementById('EnemyForts').value        = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyForts'         );
document.getElementById('EnemyRank').value         = prefService.getIntPref('extensions.Ultima.MilitaryCalculatorEnemyRank'          );
document.getElementById('EnemyMonarchBox').checked    = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorEnemyMonarchBox'    );
document.getElementById('EnemyPeasantsBox').checked   = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorEnemyPeasantsBox'   );
document.getElementById('EnemyFanaticismBox').checked = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorEnemyFanaticismBox' );
document.getElementById('EnemyAggressionBox').checked = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorEnemyAggressionBox' );
document.getElementById('EnemyProtectionBox').checked = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorEnemyProtectionBox' );
document.getElementById('EnemyPlagueBox').checked     = prefService.getBoolPref('extensions.Ultima.MilitaryCalculatorEnemyPlagueBox'     );


function SaveAllValues() {

prefService.setCharPref('extensions.Ultima.MilitaryCalculatorYourProvinceName' , document.getElementById('YourProvinceName').innerHTML );

prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourRace'          , document.getElementById('YourRace').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourPersonality'   , document.getElementById('YourPersonality').value   );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourRelations'     , document.getElementById('YourRelations').value     );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourStance'        , document.getElementById('YourStance').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourDragon'        , document.getElementById('YourDragon').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourSoldiers'      , document.getElementById('YourSoldiers').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourOffSpecs'      , document.getElementById('YourOffSpecs').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourDefSpecs'      , document.getElementById('YourDefSpecs').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourElites'        , document.getElementById('YourElites').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourLand'          , document.getElementById('YourLand').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourNW'            , document.getElementById('YourNW').value            );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourKDNW'          , document.getElementById('YourKDNW').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourOME'           , document.getElementById('YourOME').value * 1000000 );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourDME'           , document.getElementById('YourDME').value * 1000000 );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourGenerals'      , document.getElementById('YourGenerals').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourAttackTime'    , document.getElementById('YourAttackTime').value    );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourHorses'        , document.getElementById('YourHorses').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourMerc'          , document.getElementById('YourMerc').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourPris'          , document.getElementById('YourPris').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourMilitarySci'   , document.getElementById('YourMilitarySci').value   );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourRecentlyHit'   , document.getElementById('YourRecentlyHit').value   );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourGuardStation'  , document.getElementById('YourGuardStation').value  );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourPeasants'      , document.getElementById('YourPeasants').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourRawME'         , document.getElementById('YourRawME').value         );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourBE'            , document.getElementById('YourBE').value            );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourTG'            , document.getElementById('YourTG').value            );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourForts'         , document.getElementById('YourForts').value         );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorYourRank'          , document.getElementById('YourRank').value          );

prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorYourMonarchBox'    , document.getElementById('YourMonarchBox').checked     );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorYourPeasantsBox'   , document.getElementById('YourPeasantsBox').checked    );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorYourFanaticismBox' , document.getElementById('YourFanaticismBox').checked  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorYourAggressionBox' , document.getElementById('YourAggressionBox').checked  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorYourProtectionBox' , document.getElementById('YourProtectionBox').checked  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorYourPlagueBox'     , document.getElementById('YourPlagueBox').checked      );

prefService.setCharPref('extensions.Ultima.MilitaryCalculatorEnemyProvinceName' , document.getElementById('EnemyProvinceName').innerHTML );

prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyRace'          , document.getElementById('EnemyRace').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyPersonality'   , document.getElementById('EnemyPersonality').value   );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyRelations'     , document.getElementById('EnemyRelations').value     );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyStance'        , document.getElementById('EnemyStance').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyDragon'        , document.getElementById('EnemyDragon').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemySoldiers'      , document.getElementById('EnemySoldiers').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyOffSpecs'      , document.getElementById('EnemyOffSpecs').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyDefSpecs'      , document.getElementById('EnemyDefSpecs').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyElites'        , document.getElementById('EnemyElites').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyLand'          , document.getElementById('EnemyLand').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyNW'            , document.getElementById('EnemyNW').value            );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyKDNW'          , document.getElementById('EnemyKDNW').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyOME'           , document.getElementById('EnemyOME').value * 1000000 );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyDME'           , document.getElementById('EnemyDME').value * 1000000 );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyGenerals'      , document.getElementById('EnemyGenerals').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyAttackTime'    , document.getElementById('EnemyAttackTime').value    );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyHorses'        , document.getElementById('EnemyHorses').value        );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyMerc'          , document.getElementById('EnemyMerc').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyPris'          , document.getElementById('EnemyPris').value          );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyMilitarySci'   , document.getElementById('EnemyMilitarySci').value   );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyRecentlyHit'   , document.getElementById('EnemyRecentlyHit').value   );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyGuardStation'  , document.getElementById('EnemyGuardStation').value  );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyPeasants'      , document.getElementById('EnemyPeasants').value      );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyRawME'         , document.getElementById('EnemyRawME').value         );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyBE'            , document.getElementById('EnemyBE').value            );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyTG'            , document.getElementById('EnemyTG').value            );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyForts'         , document.getElementById('EnemyForts').value         );
prefService.setIntPref('extensions.Ultima.MilitaryCalculatorEnemyRank'          , document.getElementById('EnemyRank').value          );

prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyMonarchBox'    , document.getElementById('EnemyMonarchBox').checked     );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyPeasantsBox'   , document.getElementById('EnemyPeasantsBox').checked    );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyFanaticismBox' , document.getElementById('EnemyFanaticismBox').checked  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyAggressionBox' , document.getElementById('EnemyAggressionBox').checked  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyProtectionBox' , document.getElementById('EnemyProtectionBox').checked  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyPlagueBox'     , document.getElementById('EnemyPlagueBox').checked      );

}



function Task_Manager() {
SaveAllValues();
Task_Military();
setTimeout("Task_Manager()",1000);
}


Task_Manager();


